package info.techgeek.labs.java5Features.thread.pripority;

public class SamplePriorityTask implements PriorityTask,Comparable<PriorityTask> {

    private TaskPriorityLevel _level;
    long _enter;
    public SamplePriorityTask(TaskPriorityLevel level,long enter) {
            super();
            this._level = level;
            _enter = enter;
    }

//    @Override
    public TaskPriorityLevel getTaskPriorityLevel() {
            return _level;
    }

//    @Override
    public void run() {
            
            long start = System.nanoTime();
            
            for (int i = 0;i<50;i++){
                    recursiveMultify(5000);
            }
            
            long end = System.nanoTime();
            System.out.println(Thread.currentThread().getName() + "," + _level.name()+ "," + (end -start)+ "," + (end -_enter));
    }

    private long recursiveMultify(long i){
            if (i<=1) return 1;
            else return i*recursiveMultify(i-1);
    }

//    @Override
    public int compareTo(PriorityTask task) {
            return _level.getLevel() - task.getTaskPriorityLevel().getLevel();
    }
}

